package io.gps.datatransfer.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 配置文件加载
 */
public enum PropertiesUtils {
    PROPERTIES()
    ;

    private PropertiesUtils() {
    }

    private Properties properties = new Properties();

    public Properties getProperties(String path){
        try {
            properties.load(PropertiesUtils.class.getClassLoader().getResourceAsStream(path));
        } catch (IOException e) {
            e.printStackTrace();
        }

        return properties;
    }

    public Properties getFileProperties(String path){
        InputStream inputStream=null;
        try {
            inputStream=new FileInputStream(new File(path));
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if(inputStream!=null){
                    inputStream.close();
                }
            } catch (IOException e) {

            }
        }

        return properties;
    }

}
